<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        var conArr = [];

        function splitArrByLength(str, len) {
            var reg = new RegExp(".{" + len + "}", "g");
            var strArr = str.match(reg);
            strArr = strArr.map((item) => {
                return item.split("");
            })
            return strArr;
        }

        function findStart(arr, row, col) {
            for (var i = 0; i != row; i++) {
                for (var j = 0; j != col; j++) {
                    if (arr[i][j] != "*" && (((i-1>0)&& (arr[i - 1][j] == "*")) || ((j - 1 > 0) && (arr[i][j - 1] == "*")) || (i - 1 < 0) || (j - 1 < 0)) ) {
                        var obj = {};
                        obj.x = i;
                        obj.y = j;
                        obj.val = arr[i][j];
                        conArr.push(obj);
                    }
                }
            }
            console.log(conArr);
        }

        function answer(str, row, col) {
            var strArr = splitArrByLength(str, col);
            findStart(strArr, row, col);
        }

        answer('123*5*78', 2, 4);
    </script>
</body>

</html>